<template>
  <h1>我是主页</h1>
  <button @click="openDialog">打开对话框</button>
  <button @click="testNow">请求时间</button>
  <button @click="toLogin">返回登录页面</button>
</template>
<script setup>
import { useStore } from '@store'
import req from '@utils/request'
import { userLogin } from "../api/home";
import { useRouter } from 'vue-router'

const router = useRouter()
const store = useStore()

const openDialog = () => {
  userLogin({
    username: 'admin',
    password: 'admin',
    key: '123',
    captcha: '123'
  }).then(res => {
    console.log('请求登录得到的响应：', res);
  }).catch(err => {
    console.log('请求登录出现异常：', res);
  })
}
const testNow = () => {
  req({
    url: '/u/loginByJson',
    data: {
      username: 'admin',
      password: 'admin',
      key: '123',
      captcha: '123'
    }
  }).then(res => {
    console.log('请求登录得到的响应结果：',res);// 开发者后台响应的结果
  }).catch(err => {
    console.log('请求登录出现异常：',err);
  })
}
const toLogin = () => {
  localStorage.setItem('TOKEN','')
  router.push('/login')
}
</script>
